cmake_minimum_required( VERSION 2.6 )

project( Esi_01 )

# Some defines
add_definitions( -DHAVE_CONFIG_H )
set( CMAKE_CXX_FLAGS "-W -Wall -pedantic -ansi -std=c++98" )

set( INPUT_SIZE 256 )
set( N_VARIANCE 4 )
set( IMAGE_SIZE 512 )

set( RANDOM_NUMBERS 500 )
set( RANDOM_XMIN 0 )
set( RANDOM_XMAX 100 )
set( RANDOM_MEAN 0 )
set( RANDOM_VARIANCE 1 )

set( SINUSOID_NPOINTS 512 )

set( PARAMETRIC_NPOINTS 501 )
set( PARAMETRIC_TVALUE 200 )
set( PARAMETRIC_ERRMAX 0.02f )

# test floating point size
include(CheckTypeSize)

CHECK_TYPE_SIZE("float" SIZEOF_FLOAT)
CHECK_TYPE_SIZE("double" SIZEOF_DOUBLE)
CHECK_TYPE_SIZE("long double" SIZEOF_LONGDOUBLE)


configure_file(
	"${PROJECT_SOURCE_DIR}/config.h.in"
	"${PROJECT_BINARY_DIR}/config.h"
)
 
include_directories( "${PROJECT_BINARY_DIR}" )


include_directories( "${PROJECT_SOURCE_DIR}/numbers" )
add_subdirectory( numbers )

include_directories( "${PROJECT_SOURCE_DIR}/fft" )
add_subdirectory( fft )

include_directories( "${PROJECT_SOURCE_DIR}/inputs" )
add_subdirectory( inputs )

include_directories( "${PROJECT_SOURCE_DIR}/signals" )
add_subdirectory( signals )

include_directories( "${PROJECT_SOURCE_DIR}/exceptions" )
add_subdirectory( exceptions )

include_directories( "${PROJECT_SOURCE_DIR}/entropy" )
add_subdirectory( entropy )

include_directories( "${PROJECT_SOURCE_DIR}/noises" )
add_subdirectory( noises )

include_directories( "${PROJECT_SOURCE_DIR}/filters" )
add_subdirectory( filters )

macro( compileTest testName )
	add_executable( ${testName} ${testName}.cpp )
	target_link_libraries( ${testName} exceptions numbers fft inputs signals entropy noises filters )
endmacro( compileTest )

compileTest( "test-fft" )
compileTest( "test-isEven" )
compileTest( "test-isReal" )
compileTest( "test-firstElement" )
compileTest( "test-fft-inversa" )
compileTest( "test-gauss" )
compileTest( "test-fft-gauss" )
compileTest( "test-fft-varianze" )
compileTest( "test-fft2D-proc1" )
compileTest( "test-fft2D-proc2" )
compileTest( "test-random-numbers" )
compileTest( "test-sinusoid" )
compileTest( "test-parametric" )
compileTest( "test-noisy-sinusoids" )
compileTest( "test-filter-sinusoid" )
compileTest( "test-cosinusoid" )
compileTest( "test-filter-cosinusoid" )

# Tests
enable_testing()

# Test esercitazione 1
add_test( "f[m]_reale" test-isReal 0-8 248-255 )
add_test( "f[m]_pari" test-isEven 0-8 248-255 )
add_test( "F[0]=17" test-firstElement 0-8 248-255 )
add_test( "F_ok" test-fft 0-8 248-255 )

add_test( "g[m]_reale" test-isReal 0-16 240-255 )
add_test( "g[m]_pari" test-isEven 0-16 240-255 )
add_test( "G[0]=33" test-firstElement 0-16 240-255 )
add_test( "G_ok" test-fft 0-16 240-255 )

# Test esercitazione 2
add_test( "F_inversa" test-fft 0-8 248-255 )
add_test( "G_inversa" test-fft 0-16 240-255 )


# Documentation
find_program( DOXYGEN doxygen )

add_custom_target(
	doxygen
	"${DOXYGEN}"
	DEPENDS Doxyfile
)

